﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using QuanLyBongDa.HeThongGiaoDien;
using QuanLyBongDa.HeThongLuuTru;
using QuanLyBongDa.HeThongXuLy;

namespace QuanLyBongDa.HeThongLuuTru
{
    class KetQuaThiDau
    {
        public static bool ThemKetQua(KetQuaThiDauDTO kq)
        {
            try
            {
                string sql = "insert into KETQUATHIDAU(VongDau, Doi1, Doi2, TenSan, TySo, Ngay, Gio) values (" + kq.VongDau + ",'" + kq.Doi1 + "','" + kq.Doi2 + "','" + kq.TenSan + "', '" + kq.TySo + "', '" + kq.Ngay + "', '" + kq.Gio + "')";
                DataAccess.ExecNonQuery(sql);
                return true;

            }
            catch (Exception)
            {
                //MessageBox.Show(ex.ToString());
                return false;
            }
        }
        public static DataTable BangKetQua()
        {
            string sql = "SELECT* FROM KETQUATHIDAU";
            return DataAccess.ExecQuery(sql);
        }

        public static bool XoaKetQua(KetQuaThiDauDTO kq)
        {
            try
            {
                string sql = "Delete from KETQUATHIDAU where MaTranDau = " + kq.MaTranDau;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static bool SuaKetQua(KetQuaThiDauDTO kq)
        {
            try
            {
                string sql = "Update KETQUATHIDAU set VongDau = " + kq.VongDau + ",Doi1 = '" + kq.Doi1 + "',Doi2 = '" + kq.Doi2 + "',TenSan = '" + kq.TenSan + "',TySo = '" + kq.TySo + "',Ngay = '" + kq.Ngay + "',Gio = '" + kq.Gio + "'where MaTranDau=" + kq.MaTranDau;
                DataAccess.ExecNonQuery(sql);
                return true;

            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}
